package com.dongxing.concyrrency.chapter11;

/**
 * @author XavierDong
 **/
public class ThreadException {


    private final static int A = 10;
    private final static int B = 0;

    public static void main(String[] args) {

        new Test1().test();
        Thread t1 = new Thread(() -> {
            try {
                Thread.sleep(5_000);
                int result = A / B;
                System.out.println(result);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        // 可以获取到 run方法中的异常信息
        t1.setUncaughtExceptionHandler((thread, e) -> {
            System.out.println(e);
            System.out.println(thread);
        });
        t1.start();
    }
}
